#include <algorithm>
#include <cmath>
#include <cstdio>

typedef long long ll;

const int N = 5, inf = 0x3f3f3f3f;
ll n, maxx, maxy, minx, miny;
ll x[N], y[N];

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

inline ll solve(int i, int j) {
  return (1ll * (std::abs(x[i] - x[j]) + 1) * (std::abs(y[i] - y[j]) + 1) -
          gcd(std::abs(x[i] - x[j]), std::abs(y[i] - y[j])) - 1ll) >>
         1ll;
}

inline bool check(int i, int j, int k) { return 1ll * (j - i) * (i - k) > 0; }

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("abc.in", "r", stdin);
  freopen("abc.out", "w", stdout);
#endif
#endif

  scanf("%lld", &n);
  for (int i = 1; i <= n; ++i) {
    maxx = maxy = -inf;
    minx = miny = inf;
    for (int i = 1; i <= 3; ++i) {
      scanf("%lld%lld", &x[i], &y[i]);
      maxx = std::max(maxx, x[i]);
      maxy = std::max(maxy, y[i]);
      minx = std::min(minx, x[i]);
      miny = std::min(miny, y[i]);
    }
    ll ans = 1ll * (maxy - miny + 1) * (maxx - minx + 1);
    ans -= solve(1, 2);
    ans -= solve(1, 3);
    ans -= solve(3, 2);
    if (check(x[1], x[2], x[3]) && check(y[1], y[2], y[3]))
      ans -= std::min(std::abs((x[1] - x[3]) * (y[1] - y[2])),
                      std::abs((x[1] - x[2]) * (y[1] - y[3])));
    if (check(x[2], x[1], x[3]) && check(y[2], y[1], y[3]))
      ans -= std::min(std::abs((x[2] - x[3]) * (y[2] - y[1])),
                      std::abs((x[2] - x[1]) * (y[2] - y[3])));
    if (check(x[3], x[1], x[2]) && check(y[3], y[1], y[2]))
      ans -= std::min(std::abs((x[3] - x[1]) * (y[3] - y[2])),
                      std::abs((x[3] - x[2]) * (y[3] - y[1])));
    printf("%lld\n", ans);
  }
  return 0;
}